Add PersistentBrowserManager for automatic session persistence#270
Open
irvingpop wants to merge 1 commit intojoeyism:masterfrom
Open
Add PersistentBrowserManager for automatic session persistence#270irvingpop wants to merge 1 commit intojoeyism:masterfrom
irvingpop wants to merge 1 commit intojoeyism:masterfrom
Conversation
Implements Playwright's launch_persistent_context() to eliminate manual session.json management and provide more reliable session persistence across browser restarts. Changes: - Add PersistentBrowserManager class using persistent browser contexts - Add migrate_session_to_profile() utility for migration - Add comprehensive test suite (19 tests, all passing) - Update documentation with usage examples and migration guide - Add sample scripts demonstrating persistent profile usage - Maintain full backward compatibility with existing BrowserManager Benefits: - Automatic cookie and session persistence (no save/load cycles) - Works like real Chrome profiles (better anti-bot resistance) - Zero breaking changes to existing code Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
6 tasks
Author
|
hi @joeyism could you please take a look when you get a chance? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds native support for Playwright's
launch_persistent_context()to linkedin-scraper, providing automatic session persistence and eliminating the need for manual session.json management.Motivation
The current
BrowserManagerrequires explicitsave_session()andload_session()calls, which:Playwright's persistent context solves these issues by using actual Chromium user data directories that persist automatically.
Changes
New Classes & Functions
PersistentBrowserManager- Drop-in replacement forBrowserManagerusing persistent contexts.pageproperty (works with all existing scrapers)clear_profile()method for profile managementmigrate_session_to_profile()- Utility to migrate from session.json to persistent profilesDocumentation
Sample Scripts
samples/create_persistent_session.py- Create authenticated persistent profilesamples/scrape_person_persistent.py- Example using persistent profilesamples/migrate_session.py- Migrate existing session.json filesTests
PersistentBrowserManagerUsage Example
Before (session.json):
After (persistent profile):
Checklist